package com.newcapec.lesson3;

import com.newcapec.lesson1.Person;

import java.util.Objects;

/**
 * 面向对象的三大特性
 * 1、封装 把成员变量隐藏，公开对应的方法去访问成员变量
 * 2、继承 可以把子类中的公共特性抽象成宇哥父类，子类继承父类  子类拥有父类所有的非private修饰的资源
 */
public class Student extends Person {
    private int stuId;

    public Student() {
      super();
    }

    public Student(int age, String name, String sex, String birthday,int stuId) {
        super( age,  name,  sex,  birthday);

        this.stuId = stuId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;

        if(o instanceof Student){
            Student student = (Student) o;
            if(super.equals(student) && this.stuId == student.stuId){
                return true;
            }
        }
        return false;

    }

    @Override
    public int hashCode() {
        return super.hashCode() + Objects.hash(stuId);
    }

    public int getStuId() {
        return stuId;
    }

    public void setStuId(int stuId) {
        this.stuId = stuId;
    }

    @Override
    public String toString() {
        return super.toString()+"Student{" +
                "stuId=" + stuId +
                '}';
    }
}
